# name_list = ["小明", "小红", "小强", "Tom", "小红"]
# 列表是可变数据类型
# ===========================================================
# # 查找相关语法
# # 根据下标查找元素, 超过最大下标则报错
# print(name_list[0])
# # print(name_list[10])
# # 查找某个元素的下标: 序列.index(元素,开始,结束),
# # 返回第一个匹配项,找不到则报错
# print(name_list.index("小红"))
# # print(name_list.index("小小红"))
# # 统计元素出现的次数
# print(name_list.count("小红"))
# print(name_list.count("小红1"))
# # 统计容器内的元素个数
# print(len(name_list))
# # 判断某个元素是否在/不在容器内
# print("小红" in name_list)
# print("小红" not in name_list)
# # ---------------------------------------------
# name_list = ["小明", "小红", "小强", "Tom", "小红"]
# # 列表新增相关语法
# print(name_list)
# # 新增一个元素: 列表.append(元素), 加到列表结尾
# name_list.append("小刚")
# print(name_list)
# new_name = ["小白", "小黑"]
# name_list.append(new_name)
# print(name_list)
# # 拓展: 列表.extend(序列),将序列内每个元素追加到列表尾部
# name_list.extend(new_name)
# print(name_list)
# name_list.extend("Tom")
# print(name_list)
# name_list += new_name
# print(name_list)
# # 在指定位置添加元素: 列表.insert(下标, 元素)
# name_list.insert(1, "小绿")
# print(name_list)
# name_list.insert(-1, "小黄")
# print(name_list)
# -----------------------------------------
# # # 列表删除相关语法
# name_list = ["小明", "小红", "小强", "Tom", "小红","小明"]
# # 删除指定元素
# # del name_list[1]
# # print(name_list)
# # 删除整个列表
# # del name_list
# # print(name_list)
# # 删除某个元素: 列表.pop(下标),根据下标删除某个元素,
# # 不给参数则默认删除最后一个,且会返回删除的数据
# # res = name_list.pop(1)
# # res = name_list.pop()
# # print(name_list)
# # print(res)
# # 删除某个元素:列表.remove(元素),
# # 删除遇到的第一个匹配项,如果要删除的元素不存在,则报错
# name_list.remove("小明")
# print(name_list)
# # 清空列表
# name_list.clear()
# print(name_list)
# # -----------------------------------
# # 修改相关语法
# name_list = ["小明", "小红", "小强", "Tom", "小红", "小明"]
# # 根据下标进行修改
# name_list[3] = "汤姆"
# print(name_list)
# num_list = [1, 4, 7, 8, 5, 3, 2, 5, 7, 9, 0, 9]
# # 逆置:列表.reverse() ,会修改原始数据
# # print(num_list)
# # num_list.reverse()
# print(num_list)
# # 逆置: reversed(列表), 不会修改原始数据
# res = reversed(num_list)
# print(list(res))
# print(num_list)
# # 排序: 列表.sort()排序,默认升序, 原始数据会修改
# # num_list.sort()
# # print(num_list)
# # num_list.sort(reverse=True)  # reverse为True是降序
# # print(num_list)
# # 排序:sorted(列表) 不修改原始数据
# res = sorted(num_list,reverse=True)
# print(res)
# print(num_list)


# ===========================================
# 拷贝/复制
# name_list = ["小明", "小红", "小强", "Tom", "小红", "小明"]
# name_list2 = name_list.copy()
# print(name_list)
# print(name_list2)
# print(id(name_list))
# print(id(name_list2))

name_list = ["小明", "小红", "小强", "Tom", "小红", "小明"]

# # 循环变量
# n = 0
# # 循环判断
# while n < len(name_list):
#     # 循环体
#     print(name_list[n])
#     # 循环变量发生变化
#     n+=1

for name in name_list:
    print(name)
# 列表的嵌套取值
name_list = [['小明', '小红', '小绿'], ['Tom', 'Lily', 'Rose'], ['张三', '李四', '王五']]
print(name_list[0])
print(name_list[2][1])

# 随机分配办公室
teachers = [1, 2, 3, 4, 5, 6, 7, 8]
rooms = [[], [], []]

# 点名
for tea in teachers:
    print(tea)
    # 获取0-2的随机数
